<template>
  <div class="layout-all">
    <control :config="config" />

    <div class="layout-content">
      <el-table
        :data="tableData"
        stripe
        highlight-current-row
        style="width: 100%;margin-top:50px"
      >
      <el-table-column align="center" prop="id" label="序号" width="70" :fixed="isMobile()?'left':undefined"/>
      <el-table-column align="center" prop="card_name" label="姓名" width="100"/>
        <el-table-column align="center" prop="year" label="年龄"  width="80"/>
        <el-table-column align="center" prop="sex" label="性别" width="80">
          <template slot-scope="scope">
            <el-tag :type="type_list[scope.row.sex]">{{sex_str[scope.row.sex]}}</el-tag>
          </template>
        </el-table-column>
        <el-table-column align="center" prop="mobile" label="手机"  width="200"/>
        <el-table-column align="center" prop="nickname" label="昵称" minWidth="150">
           <template slot-scope="scope">
             <div icon="el-icon-platform-eleme" v-if="scope.row.user!=undefined" :style="{color:scope.row.user.sex==1?'#409eff':scope.row.user.sex==0?'#a4959a':'#D650BD'}" >
               {{scope.row.user.nickname}}</div>
            </template>
        </el-table-column>
        <el-table-column align="center" prop="parent_id" label="上级推荐人" width="150" >
          <template slot-scope="scope" v-if="scope.row.user!=undefined&&scope.row.user.parent_user!=undefined">
            <div v-if="scope.row.user.parent_user!=undefined" icon="el-icon-platform-eleme" :style="{color:scope.row.user.parent_user.sex==1?'#409eff':scope.row.user.parent_user.sex==0?'#a4959a':'#D650BD'}" >
              {{scope.row.user.parent_user.nickname}}
            </div>
          </template>
        </el-table-column>
        <el-table-column align="center" prop="remark" label="备注" show-overflow-tooltip/>
        <el-table-column align="center" prop="subscribe_time" label="预约时间" width="160" />
        <el-table-column align="center" prop="create_time" label="创建时间" width="160" />
      </el-table>
    </div>
    <el-pagination
      :current-page="current_page"
      :page-size="per_page"
      layout="total, prev, pager, next, jumper"
      :total="total"
      @size-change="handleSizeChange"
      @current-change="handleCurrentChange"
    />
  </div>
</template>

<script>
import control from '../../components/control/control'
export default {
  components: { control },
  data() {
    return {
      config: [
        { type: 'text', placeholder: '请输入姓名或电话', field: 'title', val: '' },
        {
          type: 'date_time',
          placeholder: '请选择日期',
          field: 'date_time',
          val: '',

        },
      ],
      value: '',
      searchWhere: {
        title: ''
      },
      tableData: [],
      sex_str: ['未知','男','女'],
      type_list: ['primary','success','warning','danger','info'],
      total: 0,
      current_page: 1,
      per_page: 14
    }
  },

  created() {
    this.onSearch()
  },
  methods: {
    // 查询
    handleSizeChange(val) {
      this.onSearch()
    },
    handleCurrentChange(val) {
      this.current_page = val
      this.onSearch()
    },
    onSearch() {
      const form = {}
      form.page = this.current_page
      form.map = this.searchWhere
      this.get('/admin/Registration/index', form, 'POST').then(e => {
        this.tableData = e.list.data
        this.per_page = e.list.per_page
        this.total = e.list.total
        this.current_page = e.list.current_page
      })
    },
  }
}
</script>

<style>
.layout-all {
  margin-top: 20px;
  margin-left: 10px;
}
.layout-content {
  margin-top: 20px;
}
</style>>
